package UVA;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

/*
 * @Author Josh Lear
 * @Date 4-15-2014
 * @Problem simple ad-hoc, mechanics
 */
public class UVA_11364 {
    public static void main (String[] args) throws IOException {
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
                System.out));
        Scanner sc = new Scanner(System.in);
        int cases = sc.nextInt();
        for (int i = 0; i < cases; i++) {
            int max = -1;
            int min = 1000;
            int n = sc.nextInt();
            for (int j = 0; j < n; j++) {
                int cur = sc.nextInt();
                max = Math.max(cur, max);
                min = Math.min(cur, min);
            }
            bw.write((2 * (max - min)) + "\n");
        }
        bw.flush();
        sc.close();
    }
}
